About Me

A picture of a woman riding a yellow mountain bike in the woods. The woman is wearing a white full-face helmet, a red and black cycling jersey with the letters 'TLD' on, and red and yellow leopard-print shorts, along with shin and elbow protection. There are large trees in the background, tape indicating the cycling course, and roots and rocks on the ground. The woman looks like she is concentrating.

  • One of two trainers on the HSMA programme @ Exeter (PenCHORD/PenARC)
  • Programming since 2012
  • Health Data Science MSc @ Exeter
  • Former NHS Analyst/Data Scientist

linkedin.com/in/sammijaderosser - Add Me On LinkedIn

github.com/Bergam0t - Follow Me On GitHub

PenCHORD

PenCHORD (the Peninsula Collaboration for Health Operational Research and Data Science) is one of the teams of PenARC.

PenCHORD began in 2010, and has worked with hundreds of local and national partners to use modelling and data science approaches to improve the operational delivery of health and social care services.

Our work is

  • applied
  • collaborative
  • impactful
  • open

PenCHORD Themes

HSMA

Optimising Clinical Pathways

Open Modelling and Data Science

A red logo of a computer monitor and horizontal computer tower underneath it, encased in a circle. Underneath the logo is the acronym 'HSMA' in bold white lettering. Beneath this is the phrase 'Find the Future in You'

A white and orange logo saying 'NIHR - Applied Research Collaboration South West Peninsula'

The Health Service Modelling Associates is a 15 month data science and operational research training and mentoring programme.

Supported by the NIHR PenARC and the NHS Digital Academy, the full programme is provided free of charge to people working in health, social care and policing and is accredited by AphA.

hsma-programme.github.io/hsma_site/ - Visit Our Website for Free Training

youtube.com/@hsma - Subscribe to our YouTube Channel

github.com/hsma-programme - Follow us on GitHub

Part 1: Pathways

Pathway Simulation: Why?

A stylised image showing very long queues outside of a hospital building

Your emergency department is struggling.

You could try a range of different things…

  • increase the number of staff available to register, triage or treat
  • increase the number of rooms or beds
  • increase the rate at which tests can be processed
  • add a new step in the process with a different kind of practitioner
  • completely redesign the pathway

Which of these is the right answer?

Queue, Queue, Barney McGrew

Healthcare tends to be full of queueing problems like this one.

  • People attending a walk-in clinic or emergency department
  • People calling a telephone-based service like 111 or a mental health crisis line
  • People on a cancer diagnosis and treatment pathway
  • People waiting to be assessed for ADHD and Autism, or on the waiting list for a gender clinic
  • People waiting for a series of treatment with a mental health practitioner
    • might have one, several or many appointments

Pathway Parts

Healthcare systems are full of resources

  • People 👩🏻‍⚕️ 👩🏿‍⚕️ 👨🏽‍⚕️ 👨🏽‍⚕️ 👩🏾‍⚕️
  • Equipment 🔬🩺
  • Rooms & cubicles 🏥
  • Beds 🛌🏻 🛌🏽 🛌🏿 🛌🏻 🛌🏼 🛌🏽 🛌🏿
  • Treatments 💉 🩹 💊
  • Vehicles 🚑 🚁 🚗

These resources experience demand from entities.

These entities might be

  • People (in person) 🤒 🤢 🤧
  • People (on the phone) ☎️
  • Test Requests 🩻 🧪

Pathways and Queues

As these entities move through a pathway - a series of steps where these resources are used - queues can build up where there isn’t enough resource.

A pathway showing several steps, starting with 'sign in with receptionist'. One person is signing in; one receptionist is in use and the other is available. A queue of 7 people is then waiting to be triaged. One person is being triaged bby the single available triage nurse. The pathway then splits; one person is seeing a nurse for treatment while two further nurses are available. There is no queue for this step. However, 8 people are waiting to be treated by the single available doctor, who is currently treating someone. People can then either be discharged, receive additional treatment from a nurse or doctor, or may require additional tests. One person is waiting for tests; one person is dealing with the tests while the other is idle. After these tests, people may be discharged, or may need to see a doctor or nurse again.

Queue What?


And these pathways are often very complicated!

There are lots of moving parts, and lots of variation.


Variation in when, and how frequently, people arrive

Variation in how long an activity in the pathway takes

Variation in the pathways people take within a single system

The Problem with Pathways

Making changes to pathways can be

  • costly
  • slow
  • unsafe!

And even if you do fix the original problem you were trying to solve, there’s a risk of knock-on effects elsewhere in the pathway that you didn’t foresee.

The Future Problems with Pathways

And even if you avoid that….

A system that is coping now might not cope

  • all the time
  • if demand increases
  • if resource temporarily decreases

It’s All a Simulation

On HSMA, we teach a couple of different computer simulation techniques.

System Dynamics

High-level technique that’s often suited to uncovering fundamental issues with pathway or wider healthcare system design

Agent-Based Simulation (ABS)

Individual-level modelling that is particularly interested in the impact of individuals’ decisions and interactions

Discrete Event Simulation (DES)

Modelling focussing on the flow of entities through a pathway and use of resources, allowing detailed investigation of capacity, queues and waits

It’s Our DEStiny



What we generally want to tackle our pathway problems in healthcare is Discrete Event Simulation (DES)

In a DES…

The top row of this diagram says 'entities' and shows stylised 'emoji' representations of 5 ill people. The next row of the diagram says 'flow through a pathway' and shows a branching diagram of a healthcare pathway with the steps 'arrive', 'sign in with receptionist', 'triaged', 'see nurse', 'see doctor', 'additional tests', 'discharge'. Some steps are optional or may be repeated more than once - the specifics are not important as it is just an indication of what is meant by 'pathway' in this context. The final row says 'using resources along the way' and shows four doctors and three beds as an indication of what resources are in these context.

DES to the Rescue

DES is so powerful because it gives us an in-silico (computer-based) reproduction of our pathway to play around with.

We can make any change we want
(e.g. more resources, higher demand, new pathway design)
safely and for free and see what impact it has on any metric we care to measure:

  • how long people wait at each step of the pathway
  • people meeting targets (e.g. 4 hour wait)
  • how much of the time the resources are utilised for


And so on!

Variation

That randomness and variation in our healthcare systems that we mentioned before? DES can cope really well with that!

Let’s imagine that people turn up to our system, on average, every 10 minutes.

However, sometimes no-one turns up for half an hour, and other times 3 people turn up simultaneously.

By using distributions we can produce random times that mimic real-world patterns.

Randomness

Taking it even further, we can harness that variation for making the most of our models.


We can hold the random patterns consistent and change resource levels or pathway design

We can hold resources or pathway design consistent and allow randomness


This allows us to be sure the changes we’re testing really are responsible for the differences

This allows us to test our system in multiple parallel universes, running it tens or even hundreds of times!

A Note About Modelling

Your DES won’t be a perfect one-to-one reproduction of the pathway you are modelling.

We have to make certain assumptions and simplifications, and we can’t capture every complexity.

However…



All models are wrong, but some are useful

• George E. P. Box

A stylised colour illustration of an older man - intended to resemble the statistician George E P Box - sitting at a desk. The man has large round glasses, a large grey pointed moustache and grey hair. He is wearing a brown suit and waistcoat with a blue patterned tie. On the wall behind him are books, and on the table is a calculator, books and a clipboard. There are also graphs and charts on the wall and on a computer monitor on the desk.

Example DES Projects

Example 1: Bladder Cancer Pathway

In this PenCHORD project, a DES model of the bladder cancer pathway at Royal Cornwall Hospitals Trust (RCHT) exposed two key system bottlenecks.

  • A delay between patients being referred and receiving their surgery
  • A delay waiting for the nurse specialist to contact the patient to discuss their diagnosis and treatment options

The model was used to support an on-the-spot rewrite of the pathway, resulting in multi-week reductions to waiting times.

Find Out More

Example 2: Vaccination Clinic

This HSMA project looked at the design of a COVID-19 vaccination clinic in North Devon, exploring

  • queue lengths
  • car park capacity
  • times for each step of the vaccination process

The model identified potential issues with the original proposed plans, and was used to refine the plans to enable a safe but efficient delivery of the vaccination programme.

Find Out More

Example 3: Emergency Department Model

This HSMA project looked at ways to improve Urgent Treatment Care (UTC) performance. The team wanted to know

  • What further staff and resources would be required for any variations in patient attendance
  • How changes in the patient pathway would reduce bottlenecks
    (e.g what would be the impact of front-loading diagnostics?)

The model identified a need for additional rooms and the ED was redesigned as a result.

Find Out More

Example 4: Mental Health Assessment Pathway Model

This PenCHORD project created a simulation model of a mental health assessment pathway.

The trust in question was piloting an approach that would allow patients to book their appointments themselves.

The model was used to help

  • predict the number of appointment slots required at each site
  • show that allowing queue-sharing between smaller groups of sites would significantly reduce the wait times

Find Out More

Example 5: Children’s Neurodiversity Assessment Pathway

This HSMA project created a model of a paediatric neurodevelopmental (ADHD + autism) pathway. Waits had increased to a 2 years on average.

The team wanted to understand

  • where current bottlenecks in the process were
  • what level of staffing would be needed to clear the existing backlog and maintain a steady state

The model showed that recruiting an extra lead clinician would not address the bottleneck - but an additional second assessor would.

Find Out More

Other Projects

You can find details about all of our previous and current Discrete Event Simulation projects on the HSMA website

An animation of someone navigating through a page of projects on the HSMA website. They scroll down to a project on simulation and click on 'details' to receive more information and find a video on the project.

Activity

DES Applications

In your groups, we’re going to spend a few minutes discussing opportunities you can see for DES in your organisation.

DES Step 1: Arrivals

Recap - Controlled Randomness

As mentioned earlier, one great thing about DES is controlled randomness.

We can work out the average time between patients arriving at the centre - maybe every 5 minutes - but we don’t want people to just turn up at exact 5-minute intervals.

That’s not very realistic, and it doesn’t help us understand how the system copes with variation.

Distributions

We sample the gap between arrivals from a distribution.

Where the bar higher, there is a greater chance that the random number picked will be somewhere around that value.

Depending on the real-world pattern we are trying to mimic, our distribution will be a different shape or peak in a different place.

DES Step 2: A Simple Pathway

DES Step 3: Branching Pathways

DES Step 4: Optimising a Complex Pathway

Doing your Own DES Projects

Conceptual Modelling

DES models (and all data science and operational research projects!) work best when there’s involvement from the start of staff involved with the pathway.

One of the key early steps of any DES project is mapping the pathway.

**TODO

Drag & Drop

There are various paid, closed-source drag-and-drop software tools for doing DES - but they are often prohibitively expensive.

Using these tools can make it hard to share your models with others.

However, If you don’t code, there is the free and open source (FOSS) tool JaamSim.

A screenshot showing the homepage of the website for the JaamSim software. It contains a link to download the software for free, as well as a video showing the use of the software and some key information about the features of the software.

DES in R

The logo for the simmer R package. It is a yellow hexagon with a darker yellow border, with the word 'simmer' at the bottom and a simple black mug containing a spoon and three white dots.



R has the simmer package.

DES in Python

In Python, there are a range of packages for DES.

The logo for the Salabim simulation package. It is the text 'salabim' in a curly, stylised red font. In smaller text below this, it says 'discete event simulation'.

Salabim is quite popular.

The logo for the ciw package. It says 'Ciw' in simple white font on a yellow background, and below it has a white circle. To the left of the circle is a rectangle missing the leftmost edge, and several smaller complete rectangles within it at the rightmost end.

I’ve also heard good things about ciw

The logo for the simpy package. It is the text 'SimPy' in green and grey, with the top of the S stylised as the head of a snake and the bottom as a cog.

But HSMA has used and taught simpy for several years. It’s mature, stable, reliable and flexible.

HSMA Training on DES

The DES lectures and activities from this year’s HSMA can be found on our website.

Module Link

Intro to DES

• What DES is and where it may be useful

• The key terminology associated with DES e.g. resources, entities, sinks

• How to simplify a real-world pathway modelling problem into a conceptual model

SimPy for DES

• The features of the SimPy package

• How to write simple simulations with SimPy

• Multi-step pathways

• Branching pathways and optional steps

Advanced Simpy

• Warm-up Periods

• Priority-based Queuing

• Resource Unavailability

• Lognormal Distributions

• Reneging

• Balking

• Jockeying

The Little Book of DES

We have also put together a free eBook that serves as a handy reference to doing DES with SimPy.

It’s packed with code snippets you can use and modify and goes beyond the lecture content, including

• appointment-based models

• reproducibility

• parallelisation

• and more!

HSMA Training on Web App Interfaces for DES

While creating these models and running a range of parameters yourself can be really powerful, getting the models into the hands of stakeholders can really enhance their adoption.

Frameworks like Streamlit can help you to quickly create interactive web app front-ends for your app.

An animation of a simulation model web interface, showing a user changing simulation parameters using sliders

The HSMA Book of Streamlit

A book cover, showing a robot surfing on a wave made of numbers

This free eBook walks you through a range of Streamlit concepts.

It then goes on to providing a walk-through of how to create a simple front-end for any DES and deploying that on a free online hosting platform.

  Click here to view the eBook

Simulation Library

This is an early-stage piece of work!

On HSMA, we’re trying to collate and visualising models from across healthcare systems.

At present, there is

  • A simple emergency department
  • An orthopaedic surgery unit
  • A simple community-based service with a single appointment
  • A complex community-based service with varying numbers of appointments and a per-clinician caseload

More will be added in the coming months.

  Click here to try them out

  Click here for the code repository

End of Simulation

Summary

  • DES is an amazing option for tackling your pathway problems

  • With ever-growing resources and community experience out there, it’s a great time to get started

  • FOSS libraries allow us to adapt and reuse models - but follow guidance to make it as easy as possible for people to stand on your shoulders!